import axios from "axios";
import React from "react";

const Index = () => {
  const id = +new Date();
  const price = 100.0;
  const title = "买了4个布洛芬";
  const pay = async () => {
    const result = await axios.post("/api/pay", { id, price, title });
    console.log(result.data.data);
    window.location.href = result.data.data;
  };
  return (
    <div>
      <div>单号：{id}</div>
      <div>金额：{price}</div>
      <div>标题：{title}</div>
      <button onClick={pay}>下单</button>
    </div>
  );
};

export default Index;
